import React from 'react';
import PropTypes from 'prop-types';
import { Form, Select } from 'antd';

const { Item } = Form;
const { Option } = Select;

// HR确认申请
const Ceo = ({ form, type, detail, processState }) => {
    const { getFieldDecorator } = form;
    const { groupCeoApproval } = detail;
    const groupCeoApprovalMsg = groupCeoApproval === '0' ? '同意' : '拒绝';
    const renderApproval = () =>
        getFieldDecorator('groupCeoApproval', {
            rules: [
                {
                    required: true,
                    message: '请选择调岗结果！'
                }
            ]
        })(
            <Select>
                <Option value="0">同意</Option>
                <Option value="1">拒绝</Option>
            </Select>
        );
    return (
        <div>
            <Item required={type === 'edit' && processState !== 'success'} label="集团CEO给予调岗结果">
                {type === 'edit' && processState !== 'success' ? renderApproval() : groupCeoApprovalMsg}
                {type === 'detail' &&
                    getFieldDecorator('groupCeoApproval', {
                        initialValue: detail.groupCeoApproval
                    })(
                        <Select style={{ display: 'none' }}>
                            <Option value="0">同意</Option>
                            <Option value="1">拒绝</Option>
                        </Select>
                    )}
            </Item>
        </div>
    );
};

Ceo.propTypes = {
    type: PropTypes.oneOf(['edit', 'detail']).isRequired
};

export default Ceo;
